package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class FifthActivity extends BaseActivity implements View.OnClickListener {

    private Integer sum = 0;
    private String s = "";
    private TextView tvSum;
    private Button restart;
    private Button exit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fifth_layout);
        initView();

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        sum = bundle.getInt("score3");
        s +=  sum.toString();

//        Toast.makeText(FifthActivity.this, "所得分数为" + sum+"s="+s, Toast.LENGTH_SHORT).show();
        tvSum.setText(s);
    }

    private void initView() {
        tvSum = (TextView) findViewById(R.id.sum);
        restart = (Button) findViewById(R.id.restart);
        exit = (Button) findViewById(R.id.exit);



        restart.setOnClickListener(this);
        exit.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.restart:
                //创建意图对象
                Intent intent = new Intent(FifthActivity.this, SecondActivity.class);

                //激活意图
                startActivity(intent);
                break;
            case R.id.exit:
                MyApplication.getInstance().exit();
                break;
        }
    }
}